package hu.bme.mit.mdsd.csipetcsapat.appstore.development;

import javax.jws.WebService;

import hu.bme.mit.mdsd.csipetcsapat.appstore.core.*;

@WebService(endpointInterface = "hu.bme.mit.mdsd.csipetcsapat.appstore.development.DeterminePublication")
public class DeterminePublicationService implements DeterminePublication {
	private final String name = "DeterminePublication";
	private final String publicity = "PUBLIC";
	
	/*
	 * Get service name
	 */
	public String getName() {
		return this.name;
	}
	
	/*
	 * Get service publicity
	 */
	public String getPublicity() {
		return this.publicity;
	} 
	
	@Override
	public void determinePublication(User user, Application application, boolean decision) throws Exception {
		if(AccessModerator.hasAccess(user, this.name)) {
			/*
			 * Calling DeterminePublication.calledServices
			 */
			// Calling AutoverifyApplicationService
			Application appToVerify = null ; // Has to be defined
			AutoverifyApplication autoverifyApplication = new AutoverifyApplicationService();
			autoverifyApplication.autoverifyApplication(user, appToVerify);
			
			// Calling TestApplicationService
			Application appToTest = null ; // Has to be defined
			TestApplication testApplication = new TestApplicationService();
			testApplication.testApplication(user, appToTest);
			
			// TODO
			throw new Exception("Service is not implemented yet!");
			
		} else {
			throw new Exception("Not authorized to call this service!");
		}
	}
}
